<%@page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!-- public quote -->
<%@include file="/jsp/comm_css_include.jsp"%>
<link href="${basePath }/css/timeline.css?v=2342" rel="stylesheet">
<!doctype html>
<html>
<head>
	<style type="text/css">
		#tabb {
		    border-top: 1px solid #e7eaec;
		}
	</style>
</head>
<body class="gray-bg">
	<!--隐藏域 -->
<!-- 	<input type="hidden" id="bankRatec"/> -->
	<!--隐藏域 -->
	<div class="container creditbody">
		<div class="iboxtitle">
		 	<span><i class="glyphicon glyphicon-map-marker"></i>&nbsp;申请修改贷款信息</span>
	        </div>
	        <div class="buttonfixed">
			<button type="button" id="save"  class="btn dpbtn_blue btnaplly" onclick="saveOrUpdateLoan();">保存提交</button>
			<button type="button" id="update" style="display:none;" class="btn dpbtn_blue btnaplly" onclick="saveOrUpdateLoan();">保存提交</button>
		</div>
	   <div class="ibox-content ibox-con">
			<%@include file="/jsp/comm_yw_info_include_nohis.jsp"%>
			<div class="business-manwife">车辆信息</div>
			<div class="tche-padding tancQa">
				<table cellpadding="0" cellspacing="0" border="0" class="infor-table list-table-detail" id="used-car">
					<tr>
						<td align="right"><label class="control-label np">车辆性质：</label></td>
						<td><div class="control-div np" >${ywBusinessCar.carTypeDisplay }</div></td>
						<td style="display: none;"><mytag:selectTag id="carType" name="carType" others="class='select-control' required='required' disabled='disabled'" map="${carType }" selected="${ywBusinessCar.carType }" /></td>
						<td align="right" style="display: none;"><label class="control-label np">启用日期：</label></td>
						<td style="display: none;"><input id="startDate" name="startDate" readonly="readonly" type="text" class="select-control" value='<fmt:formatDate value="${ywBusinessCar.startDate }" pattern="yyyy-MM-dd"/>' /></td>
					</tr>
				</table>
			</div>
			
			<%@include file="/web/system/kehubiao/chelxxc.jsp"%>
			<div class="business-manwife">车贷信息（新）</div>
			<%@include file="/web/system/yw/loan_include.jsp"%>
			
			<form class="form-horizontal" id="commentFormfanli">
				<div class="business-manwife">返利方式</div>
				<div class="business-padding">
					<table cellpadding="0" cellspacing="0" border="0" class="buyinfor-table">
						<tr>
							<td align="right"><label class="control-label np">返利方式：</label>
							</td>
							<td>
								<select id="rebateTypeHidden" name="rebateTypeHidden" class="form-control"></select>
							</td>
						</tr>
					</table>
				</div>
				<div class="business-manwife">修改原因</div>
				<div class="business-padding">
				<table cellpadding="0" cellspacing="0" border="0" class="buyinfor-table">
					<tr>
	            		<td align="right" valign="top">
							<label class="control-label np">修改原因：</label>
						</td>
	            	
						<td>
	                        <textarea id="remarksc" name="remarksc" rows="3" cols="100" class="form-control"></textarea>
						</td>
					</tr>
				</table>
			</div>	
			</form>
			<div class="business-manwife">垫款调整信息</div>
			<div class="tche-padding">
				<table cellpadding="0" cellspacing="0" border="0" class="thead-tabletz">
					<thead class="thead-a">
						<tr>
							<th></th>
							<th>原值</th>
							<th>新值</th>
							<th>调整值</th>
						</tr>
					</thead>
					<tbody class="tbody-a">
						<tr>
							<td>经销商返利</td>
							<td><input class="tbody-control" readonly="readonly" type="number" id="rebateDealerOldc" name="rebateDealerOld" value="${empty ywFees.rebateDealer ? '0' : ywFees.rebateDealer}" /></td>
							<td><input onkeyup="countaa();" class="tbody-control" type="number" id="rebateDealerNewc" name="rebateDealerNew" /></td>
							<td><input class="tbody-control" readonly="readonly" type="number" id="rebateDealerAdjustc" name="rebateDealerAdjust" value="0"/></td>
						</tr>
						<tr>
							<td>分公司展业费</td>
							<td><input class="tbody-control" readonly="readonly" type="number" id="rebateProvinceOldc" name="rebateProvinceOld" value="${empty ywFees.rebateProvince ? '0' : ywFees.rebateProvince}" /></td>
							<td><input onkeyup="countbb();" class="tbody-control" type="number" id="rebateProvinceNewc" name="rebateProvinceNew" /></td>
							<td><input class="tbody-control" readonly="readonly" type="number" id="rebateProvinceAdjustc" name="rebateProvinceAdjust" value="0"/></td>
						</tr>
						<tr>
							<td>区域&业务员展业费</td>
							<td><input class="tbody-control" readonly="readonly" type="number" id="rebateAreaOldc" name="rebateAreaOld" value="${empty ywFees.rebateArea ? '0' : ywFees.rebateArea}" /></td>
							<td><input onkeyup="countcc();" class="tbody-control" type="number" id="rebateAreaNewc" name="rebateAreaNew"  /></td>
							<td><input class="tbody-control" readonly="readonly" type="number" id="rebateAreaAdjustc" name="rebateAreaAdjust" value="0"/></td>
						</tr>

					</tbody>
				</table>
			</div>
		</div>
	</div>	
	
	<!-- public quote -->
    <%@include file="/jsp/comm_js_include.jsp"%>
    
    <!-- 车贷信息 -->
	<%@include file="/web/system/yw/loan_js_include.jsp"%>
	
	<!-- layerDate plugin javascript -->
    <script src="${basePath}/js/plugins/layer/laydate/laydate.js"></script>

    <script type="text/javascript">
	    $(function(){
		     $.dpAjax({
		    	show:false,
		    	url:'${basePath}/DataDictionaryController/getEnableList',
					data:{
						"parentValue":"Rebate_Type"
					},
					success: function(datas){
						var result = datas.result.rows;
 					    var html='<option value="">请选择</option>';
 				        for(var i=0,len=result.length;i<len;i++){
 				           var programme = result[i];
 				           html +='<option value="'+programme.value+'">'+programme.name+'</option>';
 				         }
	 				     $("#rebateTypeHidden").html(html);
						 return;
		          }
		    }); 
	    })
	    
    	$(function(){
    		$('.displayNone').hide();
    		$('.noneStyle').hide();
    		$('#carPrice').removeAttr('readonly');
	 		$('#servicePrice').removeAttr('readonly');
	 		 //判断二手车显示估价
	        $("#carType").change(function(){
	        	changeCarType();
	        });
	        $('#saveLoan').click(function(){
	        	saveLoanC();
	        });
	        
	        getcdData();
	        xitongguJia(); 
	 	});
	 	
	 	function changeCarType(){
	    	adapterCarType();
	 	}
	 	function saveOrUpdateLoan(){
	 		saveLoanC(function(){
		 		var data={};
		 		var url='${basePath}/YwBusinessLoanEditController/saveLoan';
		 		data.busiId=$.getUrlData("busiId");
		 		data.id=$.getUrlData("loanEditId");
		 		data.hisLoanId=$.getUrlData("hisLoanId");
		 		data.rebateDealerOld=$("#rebateDealerOldc").val();
		 		data.rebateDealer=$("#rebateDealerNewc").val();
		 		data.rebateProvinceOld=$("#rebateProvinceOldc").val();
		 		data.rebateProvince=$("#rebateProvinceNewc").val();
		 		data.rebateAreaOld=$("#rebateAreaOldc").val();
		 		data.rebateArea=$("#rebateAreaNewc").val();
		 		data.rebateType=$("#rebateTypeHidden").val();
		 		data.cusId=$.getUrlData("cusId");
		 		data.remarks=$("#remarksc").val();
		 		data.carType=$("#carType").val();
		 		var carAge = $("#carAge").val();
		 		data.carAge= carAge && carAge != '' ? parseInt(carAge) : 0;
		 		data.bankRateAmount=$("#bankRateAmount").val()==""?0:$("#bankRateAmount").val();
				
				data.carId=$("#zzj_carId").val();
				data.carEstimatePrice=$("#carEstimatePrice").val()==""?0:$("#carEstimatePrice").val();
				
				data.loanBank=$("#loanBank").val();
				data.loanType=$("#loanType").val();
				data.loanMonth=$("#loanMonth").val()==""?0:$("#loanMonth").val();
				data.carPrice=$("#carPrice").val();
				data.loanAmount=$("#loanAmount").val()==""?0:$("#loanAmount").val();
				data.servicePrice=$("#servicePrice").val()==""?0:$("#servicePrice").val();
				data.signLoanAmount=$("#signLoanAmount").val()==""?0:$("#signLoanAmount").val();
				data.totalRepaymentAmount=$("#totalRepaymentAmount").val()==""?0:$("#totalRepaymentAmount").val();
				data.bankRateAmount=$("#bankRateAmount").val()==""?0:$("#bankRateAmount").val();
				data.amountMonthly=$("#amountMonthly").val()==""?0:$("#amountMonthly").val();
				data.zhkcj=$("#zhkcj").val()==""?0:$("#zhkcj").val();
				data.qyhkcj=$("#qyhkcj").val()==""?0:$("#qyhkcj").val();
				data.bankRate=$("#bankRate").val()==""?0:$("#bankRate").val() / 100;
				data.ccol2=$("#ccol2").val()==""?0:$("#ccol2").val()/100;
				data.ccol1=$("#ccol1").val();
				data.companyRate=$("#companyRate").val()==""?0:$("#companyRate").val() / 100;
				data.firstMonthTotalAmount=$("#firstMonthTotalAmount").val()==""?0:$("#firstMonthTotalAmount").val();
				data.monthlyPrincipalAmount=$("#monthlyPrincipalAmount").val()==""?0:$("#monthlyPrincipalAmount").val();
				data.firstMonthAmount=$("#firstMonthAmount").val()==""?0:$("#firstMonthAmount").val();
				data.monthlyFee=$("#monthlyFee").val()==""?0:$("#monthlyFee").val();
				data.firstMonthFee=$("#firstMonthFee").val()==""?0:$("#firstMonthFee").val();
				data.firstPaymentAmount = $('#firstPaymentAmount').val();
				data.stagesFee2 = $('#stagesFee2').val();
				data.stagesFee = $('#stagesFee').val();
				
				data.firstPaymentAmount = $('#firstPaymentAmount').val();
				
				data.trialAssureRate = $('#trialAssureRate').val() / 100;
				data.assureAmount = $('#assureAmount').val();
				data.stageAmount = $('#stageAmount').val();
 				data.fqbl = $('#fqbl').val() / 100;
 				data.signFirstPaymentAmount=$("#signFirstPaymentAmount").val();
 				
				var remarks = $('#remarks').val();
				if(remarks==""){
		 			layer.msg("修改原因未填写，请仔细检查！",{icon:7});
		 			return;
		 		}
				var validstatus = $("#commentFormfanli").valid();
		 		if(!validstatus){
		 			layer.msg("有验证未通过，请仔细检查！",{icon:7});
		 			return;
		 		}
		 		$.dpAjax({
			    	url:url,
		 			data:data,
		 			success: function(datas){
		 				window.location.href="${basePath}/web/ywShouLi/sqUpdatedaikuanList.jsp";
		 				 layer.msg('执行成功！', {icon: 6});
		            }
			   });
	 		});
	 	}
	 	
	 	function saveLoanC(fn){
	 		var carType = $('#carType').val();
	 		var loanMonth = $('#loanMonth').val();
	 		var carAge  = $('#carAge').val();
	 		if(carType == '02') { //二手车
	 			var continuedMonths = countContinuedMonths();
	 			if(continuedMonths > 120) {
	 				layer.msg('不符合贷款要求，建议调整贷款期', {icon: 5});
	 				return;
	 			}
	 		}
	 		
	 		var validstatus = $("#commentFormd").valid();
	 		if(!validstatus){
	 			layer.msg("有验证未通过，请仔细检查！",{icon:7});
	 			return;
	 		}
	 		
	 		var data = {};
	 		var id = $('#loanId').val();
	 		data.busiId = $.getUrlData("busiId");
	 		data.cusId = $("#customerId").val();
	 		data.carType = $('#carType').val();
	 		//输入字段
	 		data.loanBank = $('#loanBank').val();
	 		data.loanType = $('#loanType').val();
	 		data.carPrice = $('#carPrice').val();
	 		data.carEstimatePrice = $('#carEstimatePrice').val();
	 		data.carAge = $('#carAge').val();
	 		data.loanMonth = $('#loanMonth').val();
	 		data.loanAmount = $('#loanAmount').val();
	 		data.servicePrice = $('#servicePrice').val();
	 		data.ccol2 = $('#ccol2').val() / 100;
	 		data.bankRate= $('#bankRate').val() / 100;
	 		
	 		//结果字段
	 		data.signLoanAmount = $('#signLoanAmount').val();
	 		data.totalRepaymentAmount = $('#totalRepaymentAmount').val();
	 		data.amountMonthly = $('#amountMonthly').val();
	 		data.firstMonthTotalAmount = $('#firstMonthTotalAmount').val();
	 		data.monthlyPrincipalAmount = $('#monthlyPrincipalAmount').val();
	 		data.monthlyFee = $('#monthlyFee').val();
	 		data.firstMonthAmount = $('#firstMonthAmount').val();
	 		data.firstMonthFee = $('#firstMonthFee').val();
	 		data.ccol1 = $('#ccol1').val();
	 		data.firstPaymentAmount = $('#firstPaymentAmount').val();
	 		
	 		data.trialAssureRate = $('#trialAssureRate').val() / 100;
	 		data.assureAmount = $('#assureAmount').val();
	 		data.stageAmount = $('#stageAmount').val();
 	 		data.fqbl = $('#fqbl').val() / 100;
	 		data.signFirstPaymentAmount = $('#signFirstPaymentAmount').val();
	 		
	 		$.dpAjax({
	 	 		url:'${basePath}/YwBusinessLoanController/saveWithOut',
	 			data:data,
	 			success: function(datas){
	 					if(!fn){
	 						layer.msg('车贷计算成功，请注意保存当前车辆信息', {icon: 5,time:4000});
	 					}
	 					var record = datas.result;
	 					$('#loanId').val(record.replaceId);
	 					//结果字段
	 					$('#signLoanAmount').val(showNumber(record.signLoanAmount));
	 					$('#signLoanAmountNew').val(showNumber(record.signLoanAmount));
	 					$('#loanAmountNew').val(showNumber(record.loanAmount));
	 					$('#totalRepaymentAmount').val(showNumber(record.totalRepaymentAmount));
	 					$('#bankRateAmount').val(showNumber(record.bankRateAmount));
	 					$('#amountMonthly').val(showNumber(record.amountMonthly));
	 					$('#zhkcj').val(showNumber(record.zhkcj * 100));
	 					$('#qyhkcj').val(showNumber(record.qyhkcj * 100));
	 					warning();
	 					$('#companyRate').val(showNumber(record.companyRate ? record.companyRate * 100: 0, 4));
	 					$('#firstMonthTotalAmount').val(showNumber(record.firstMonthTotalAmount));
	 					$('#monthlyPrincipalAmount').val(showNumber(record.monthlyPrincipalAmount));
	 					$('#firstMonthAmount').val(showNumber(record.firstMonthAmount));
	 					$('#monthlyFee').val(showNumber(record.monthlyFee));
	 					$('#firstMonthFee').val(showNumber(record.firstMonthFee));
	 					$("#carAge").val(record.carAge);
	 					
	 					$('#servicePrice').val(showNumber(record.servicePrice));
	 					$("#firstPaymentAmount").val(showNumber(record.firstPaymentAmount));
	 					$('#stagesFee2').val(showNumber(record.stagesFee2));
	 					$('#stagesFee').val(showNumber(record.stagesFee));
	 					
	 					$('#trialAssureRate').val(showNumber(record.trialAssureRate ? record.trialAssureRate * 100 : 0, 4));
	 					$('#assureAmount').val(showNumber(record.assureAmount));
	 					$('#stageAmount').val(showNumber(record.stageAmount));
 	 					$('#fqbl').val(showNumber(record.fqbl ? record.fqbl * 100 : 0, 4));
 	 					$('#signFirstPaymentAmount').val(showNumber(record.signFirstPaymentAmount));
 	 					
	 					countaa();
	 					countbb();
	 					countcc();
	 					if(fn) {
	 						fn();
	 					}
	 			}
	 		});
	 	}
	 	var countcc=function(){
	 		  var signLoanAmountOld=$("#rebateAreaOldc").val()==""?"0":$("#rebateAreaOldc").val();
	 		  var signLoanAmountNew=$("#rebateAreaNewc").val()==""?"0":$("#rebateAreaNewc").val();
	 		  $("#rebateAreaAdjustc").val((parseFloat(signLoanAmountNew)-parseFloat(signLoanAmountOld)).toFixed(2));
	 	  }
	 	var countbb=function(){
	 		  var loanAmountOld=$("#rebateProvinceOldc").val()==""?"0":$("#rebateProvinceOldc").val();
	 		  var loanAmountNew=$("#rebateProvinceNewc").val()==""?"0":$("#rebateProvinceNewc").val();
	 		  $("#rebateProvinceAdjustc").val((parseFloat(loanAmountNew)-parseFloat(loanAmountOld)).toFixed(2));
	 	}
	 	var countaa=function(){
	 		  var rebateDealerOld=$("#rebateDealerOldc").val()==""?"0":$("#rebateDealerOldc").val();
	 		  var rebateDealerNew=$("#rebateDealerNewc").val()==""?"0":$("#rebateDealerNewc").val();
	 		  $("#rebateDealerAdjustc").val((parseFloat(rebateDealerNew)-parseFloat(rebateDealerOld)).toFixed(2));
	 	}
	 	
	 	//显影选项卡
	 	function showLoanB(){
	 		var loanBank = $('#loanBank').val();
	 		if(loanBank == 'ICBC') {
	 			$('.bank2').hide();
	 			$('.bank1').show();
	 		} else if(loanBank == 'BOC') {
	 			$('.bank1').hide();
	 			$('.bank2').show();
	 		}else if(loanBank == 'TJICBC') {
	 			$('.bank2').hide();
	 			$('.bank1').show();
	 		}
	 		showType();
	 	}
	 	var getcdData=function(){
 	    	var data={};
 	 		data.id=$.getUrlData("busiId");
 	 		$.dpAjax({
 	 			show:false,
 	    		url:'${basePath}/YwBusinessLoanController/getMultiById',
 	    		data:data,
 				success: function(datas){
 					 saveIndex = 0;
    				 var ywBusinessCar = datas.result.ywBusinessCar;
     				 if(ywBusinessCar) {
     					$('#carId').val(ywBusinessCar.replaceId);
						var price = ywBusinessCar.price ? ywBusinessCar.price.toFixed(2) : '';
						$('#carPrice').val(price);
     				 }
     				 
     				//取整模式
     				 var intTypes = datas.result.intTypes;
     				 if(intTypes) {
     					 var html = '';
     					 for(var i in intTypes) {
     						 var intType = intTypes[i];
     						 html += '<option value="' + intType.value +'">'+intType.name +'</option>';
     					 }
     					$('#ccol1').html(html);
     				 } else {
     					 $('#ccol1').html('<option value="">--没有配置取整模式--</option>');
     				 }
     				 
     				 var loanBankk;
     				//车贷信息
 					var ywBusinessLoan = datas.result.ywBusinessLoan;
 					var ywFees={};
 					if(ywBusinessLoan) {
 						var ywFeesresult = datas.result.ywFees;
 						if(ywFeesresult && ywFeesresult != null){
	 						ywFees=datas.result.ywFees.rebateType;
	 						$("#rebateTypeHidden").val(ywFees);
 						}else{
 							$("#rebateTypeHidden").val("");
 						} 
 						$("#carAge").val(ywBusinessLoan.carAge);
 						loanBankk=ywBusinessLoan.loanBank;
 						showLoanDataB(ywBusinessLoan);
 						showLoanDataC(ywBusinessLoan);
 					}
 					var ywBusinessLoanEdit = datas.result.ywBusinessLoanEdit;
 					if(ywBusinessLoanEdit) {
 						loanBankk=ywBusinessLoanEdit.loanBank;
 						ywFees=ywBusinessLoanEdit.rebateType;
 						$("#rebateTypeHidden").val(ywFees);
 						showLoanDataBEdit(ywBusinessLoanEdit);
 					}
					//贷款银行
     				 var loanBanks = datas.result.loanBanks;
     				 if(loanBanks) {
     					 var html = '';
     					 for(var i in loanBanks) {
     						 var loanBank = loanBanks[i];
     						 html += '<option value="'+loanBank.value +'">' + loanBank.name +'</option>';
     						 $('#loanBank').html(html);
     						 if(loanBank.value == loanBankk ){
     							$('#loanBank').val(loanBank.value);
     							var bankRate = $('#fast_bankRate').val();
     							initBankRate(bankRate, function(bankRate){
     					 			$('#bankRate').val(bankRate);
     					 		});
     							showLoanB();
     						 }
     					 }
     				 } else {
     					 $('#loanBank').html('<option value="">--没有配置贷款银行--</option>');
     				 }
     				 
     				changeCarType();
 	            }
 	    	});
 	    }
	 	
	 	function showLoanDataBEdit(ywBusinessLoanEdit) {
	 		var bankRate_ = showNumber(ywBusinessLoanEdit.bankRate ? ywBusinessLoanEdit.bankRate * 100 : 0, 4); 
	 		$('#fast_bankRate').val(bankRate_);
	 		
	 		$('#loanId').val(ywBusinessLoanEdit.replaceId);
	 	  	if(ywBusinessLoanEdit.loanBank && ywBusinessLoanEdit.loanBank != '') {
	 	  		$('#loanBank').val(ywBusinessLoanEdit.loanBank);
	 	  	}
	 		showLoanB();
	 		$('#loanType').val(ywBusinessLoanEdit.loanType);
	 		showType();
	 		var price = $('#price').val();
	 		$('#carPrice').val(!price || price == '' ? showNumber(ywBusinessLoanEdit.carPrice) : price);
	 		$('#carEstimatePrice').val(showNumber(ywBusinessLoanEdit.carEstimatePrice));
	 		$('#carAge').val(ywBusinessLoanEdit.carAge);
	 		$('#loanMonth').val(ywBusinessLoanEdit.loanMonth);
	 		$('#loanAmount').val(showNumber(ywBusinessLoanEdit.loanAmount));
	 		$('#companyRate').val(showNumber(ywBusinessLoanEdit.companyRate ? ywBusinessLoanEdit.companyRate * 100: 0, 4));
	 		$('#ccol2').val(showNumber((ywBusinessLoanEdit.ccol2 && ywBusinessLoanEdit.ccol2 != '')? parseFloat(ywBusinessLoanEdit.ccol2)*100 : 0, 4));
	 		$('#servicePrice').val(showNumber(ywBusinessLoanEdit.ywBusinessLoanEdit));
	 		$('#ccol1').val(ywBusinessLoanEdit.ccol1);
	 		
	 		//结果字段
	 		$('#signLoanAmount').val(showNumber(ywBusinessLoanEdit.signLoanAmount));
	 		$('#totalRepaymentAmount').val(showNumber(ywBusinessLoanEdit.totalRepaymentAmount));
	 		$('#bankRateAmount').val(showNumber(ywBusinessLoanEdit.bankRateAmount));
	 		$('.amountMonthly').val(showNumber(ywBusinessLoanEdit.amountMonthly));
	 	    $('#zhkcj').val(showNumber(ywBusinessLoanEdit.zhkcj * 100));
	 	    $('#qyhkcj').val(showNumber(ywBusinessLoanEdit.qyhkcj * 100));
	 	    warning();
	 		$('#firstMonthTotalAmount').val(showNumber(ywBusinessLoanEdit.firstMonthTotalAmount));
	 		$('#monthlyPrincipalAmount').val(showNumber(ywBusinessLoanEdit.monthlyPrincipalAmount));
	 		$('#firstMonthAmount').val(showNumber(ywBusinessLoanEdit.firstMonthAmount));
	 		$('#monthlyFee').val(showNumber(ywBusinessLoanEdit.monthlyFee));
	 		$('#firstMonthFee').val(showNumber(ywBusinessLoanEdit.firstMonthFee));
	 		//modify by zzj
	 		$('#rebateTypeHidden').val(ywBusinessLoanEdit.rebateType);
	 		$("#rebateDealerNewc").val(ywBusinessLoanEdit.rebateDealer);
	 		$("#rebateProvinceNewc").val(ywBusinessLoanEdit.rebateProvince);
	 		$("#rebateAreaNewc").val(ywBusinessLoanEdit.rebateArea); 
	 		$("#amountMonthly").val(ywBusinessLoanEdit.amountMonthly);
	 		$("#servicePrice").val(ywBusinessLoanEdit.servicePrice);
			$('#firstPaymentAmount').val(showNumber(ywBusinessLoanEdit.firstPaymentAmount));
	 		$("#remarksc").val(ywBusinessLoanEdit.remarks);
	 		$("#loan_trialAssureRatec").text(showNumber(ywBusinessLoanEdit.trialAssureRate ? ywBusinessLoanEdit.trialAssureRate * 100 : 0, 4));
			$('#loan_assureAmountc').text(showNumber(ywBusinessLoanEdit.assureAmount));
			$('#loan_stageAmountc').text(showNumber(ywBusinessLoanEdit.stageAmount));
			$('#loan_fqblc').text(showNumber(ywBusinessLoanEdit.fqbl ? ywBusinessLoanEdit.fqbl * 100 : 0, 2));
			$('#loan_signFirstPaymentAmountc').text(showNumber(ywBusinessLoanEdit.signFirstPaymentAmount));
			
	 			countaa();
				countbb();
				countcc();
	 		
	 	}
 	function showWarningUsedIcbc(){
 		$('#zhkcj_showc').text('已＞80% 建议调整');
 		$('#qyhkcj_showc').text('已＞70% 建议调整');
 	}
 	function showWarningNewIcbc(){
 		$('#zhkcj_showc').text('已＞90% 建议调整');
 		$('#qyhkcj_showc').text('已＞80% 建议调整');
 	}
 	function showWarningUsedBoc(){
 		$('#zhkcj_showc').text('已＞70% 建议调整');
 		$('#qyhkcj_showc').text('已＞70% 建议调整');
 	}
	 	/* 弹窗嵌套估价 */
	 	function xitongguJia(){
	 		$.dpAjax({
		    	url:'${basePath}/DataDictionaryController/getEnableList',
	 			data:{"parentValue":"Website_Usedcar"},
	 			success: function(datas){
 					  var result = datas.result.rows;
 					  var content="";
 					  for(var i=0; i<result.length;i++){
 						  var href = result[i].remarks;
 						  var name = result[i].name;
 						  content +='<div class="gujiamenu btn dpbtn_green" onclick="layeropen(\''+href+'\')">'+name+'</div>';
 					  }
 					 $("#xitongGj").append(content);
	              }
		   });
	 	}
	 	
	 	function layeropen(href){
	 	   layer.open({
			  type: 2,
			  area: ['80%', '80%'], //宽高
			  content:href,
			});
	 	} 
	 	
	 	function adapterCarType(){
		    warning();
        	if($("#carType").val() == '02') {
        		$('.usedCar').show();
        		$('#carAge').attr('required','');
        		$('#carEstimatePrice').attr('required','');
        	} else {
        		$('.usedCar').hide();
        		$('#carAge').removeAttr('required');
        		$('#carEstimatePrice').removeAttr('required');
        	}
        }
		
	 	
	    $(function(){	
	    	$("#commentFormd").validate({
		        rules: {
		        	carAge:{
		        		min:0
		        	},
		        	carEstimatePrice:{
		        		min:1
		        	},
		        	bankRate:{
		        		min:0
		        	},
		        	loanAmount:{
		        		min:0
		        	},
		        	companyRate:{
		        		min:0
		        	},
		        	carPrice:{
		        		allMoney:true
		        	},
		        	loanAmount:{
		        		allMoney:true
		        	},
		        },
		        messages: {
		        	carAge:{
		        		min:"请输入不能小于0的值"
		        	},
		        	carEstimatePrice:{
		        		min:"请输入不能小于0的值"
		        	},
		        	bankRate:{
		        		min:"请输入不能小于0的值"
		        	},
		        	loanAmount:{
		        		min:"请输入不能小于0的值"
		        	},
		        	companyRate:{
		        		min:"请输入不能小于0的值"
		        	}
		        },
		        //重写showErrors
		        showErrors: function (errorMap, errorList) {
		            $.each(errorList, function (i, v) {
		            	 layer.tips(v.message, v.element, { time: 1500 });
		                 
		                return false;
		            });  
		        },
		        /* 失去焦点时验证 */
		        onfocusout: function(element) {$(element).valid(); },
		        /*  键盘抬起不验证 */
		        onkeyup:false,
		    });
	    	
	    	$("#commentFormfanli").validate({
		        //重写showErrors
		        showErrors: function (errorMap, errorList) {
		            $.each(errorList, function (i, v) {
		            	 layer.tips(v.message, v.element, { time: 1500 });
		                 
		                return false;
		            });  
		        },
		        /* 失去焦点时验证 */
		        onfocusout: function(element) {$(element).valid(); },
		        /*  键盘抬起不验证 */
		        onkeyup:false,
		    });
	    	
		});
    	
    </script>
</body>
</html>
